package org.teremail.smtp.commands;

import static java.lang.String.format;

import java.util.List;

import org.teremail.smtp.SMTPCommandFactory;
import org.teremail.smtp.SMTPSession;

/**
 * Handles a client initiated closing of the connection.
 * 
 * @author mike
 *
 */
public class QUITCommand extends SMTPCommand {

    private static final String MSG_211 = "221 %s closing connection";


    public QUITCommand() {
        super("QUIT", EMPTY);
    }
    
    @Override
    public void process(SMTPSession session) {
        session.close(format(MSG_211, session.getHostName()));
    }

    public static final SMTPCommandFactory FACTORY = new SMTPCommandFactory() {
        public SMTPCommand create(List<String> parameters) {
            return new QUITCommand();
        }
    };

}
